package com.ibeetl.vo;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;

import java.io.Serializable;

@Slf4j
@Data
public class RespBaseVo<M> implements Serializable {



    @ApiModelProperty(value="返回编码")
    private String statusCode;
    @ApiModelProperty(value="返回标识")
    private Boolean success;
    @ApiModelProperty(value="返回说明")
    private String message;
    @ApiModelProperty(value="返回内容")
    private M data;

    private RespBaseVo() {

    }
    /**
     *
     * @return
     */
    public static RespBaseVo success() {
        RespBaseVo responseVo = new RespBaseVo();
        responseVo.setStatusCode("200");
        responseVo.setSuccess(true);
        responseVo.setMessage("ok");
        return responseVo;
    }

    /**
     *
     * @return
     */
    public static RespBaseVo success(String msg) {
        RespBaseVo responseVo = new RespBaseVo();
        responseVo.setStatusCode("200");
        responseVo.setSuccess(true);
        responseVo.setMessage(msg);
        responseVo.setData(msg);
        return responseVo;
    }

    /**
     * @param m
     * @param <M>
     * @return
     */
    public static <M> RespBaseVo success(M m) {
        RespBaseVo responseVo = new RespBaseVo();
        responseVo.setStatusCode("200");
        responseVo.setSuccess(true);
        responseVo.setMessage("ok");
        responseVo.setData(m);
        return responseVo;
    }

    public static <M> RespBaseVo success(M m,String  message) {
        RespBaseVo responseVo = new RespBaseVo();
        responseVo.setStatusCode("200");
        responseVo.setSuccess(true);
        responseVo.setMessage(message);
        responseVo.setData(m);
        return responseVo;
    }
    /**
     *
     * @return
     */
    public static RespBaseVo fail() {
        RespBaseVo responseVo = new RespBaseVo();
        responseVo.setStatusCode("200");
        responseVo.setSuccess(false);
        responseVo.setMessage("fail");
        responseVo.setData("fail");
        return responseVo;
    }

    /**
     * @param msg
     * @return
     */
    public static RespBaseVo fail(String msg) {
        RespBaseVo responseVo = new RespBaseVo();
        responseVo.setStatusCode("200");
        responseVo.setSuccess(false);
        responseVo.setMessage(msg);
        responseVo.setData(msg);
        return responseVo;
    }


}
